GBML manual / Cutscenes

Cutscenes

A cutscene is a scripted sequence of steps - camera moves, pauses, dialogue, things appearing and effects - that you build on a timeline in the editor and start from code, and that takes over the game until it ends.

What a cutscene is

In a cutscene the game stops being played and starts being shown. The camera slides to a door, a character says two lines, something appears in a puff of particles, and then the player gets control back. Nothing in that needs the player, and the timing matters, so writing it as ordinary events would be awkward. Instead a cutscene is one piece of authored content, a list of steps played in order, one after another.

You build one in the editor, then start it from code with one function call. A cutscene you built has a name, and in code you write that name as a plain word: cutscene_start(cs_intro).

Building one in the Cutscenes tab

The editor's Cutscenes tab (the clapperboard) is where scenes are made. Each scene is saved in your project as its own file in the cutscenes folder. A scene has a few settings and a timeline.

Settings

The timeline is the row of steps. You add one by clicking its button, or by dragging the button into the timeline, and steps run from first to last. Times are written in seconds and turned into frames when the game is built. A frame is one picture the GBA draws, about 60 every second.

The steps

There are several kinds. Each one does its job and the scene moves on to the next, unless you tick Run with the previous step (see below).

StepWhat it does
Camera PanSlides the camera to a position over some seconds.
PauseWaits for some seconds and does nothing.
DialogueShows a text box with one or two lines, an optional portrait, and waits for the player to press A.
Return to OriginSlides the camera back to where it was when the scene started.
Camera ShakeShakes the camera with a power and a length of time. The shake then plays out by itself while the scene continues.
CreateMakes a new instance of an object at a position.
DestroyDestroys an instance that an earlier Create step in the same scene made.
Change PositionMoves that same instance to a new position at once.
Create BackgroundAdds a background at a position.
Destroy BackgroundRemoves a background that an earlier step made.
Move BackgroundMoves that background.
Start (particles)Starts a particle effect at a position. It runs until a Stop step or the end of the scene.
Burst (particles)Fires a one-shot puff of particles.
Stop (particles)Stops an effect an earlier Start step began.
Assign PathPuts an object that an earlier Create step made on a path from the Paths tab. The scene moves on at once while the object walks, and the object keeps walking after the scene ends. Choose Use speeds set in the Paths tab or your own speed, and optionally a start spot for the path's first point.
Overlay effectsStarts or stops a screen effect made in the Overlay Effects tab, or moves the middle of its shape (a spotlight, say). A started effect keeps playing after the scene until you stop it, another effect starts, or the room changes.
WaitHolds the scene until something happens: the player presses a button, an object reaches the end of its path, or a variable says so.
Run a ScriptRuns one of your scripts once, then goes on.
Cinema > LetterboxSlides black bars in from the top and bottom of the screen, or back out.
Cinema > ZoomMakes the room's zoomable background bigger or smaller.
Cinema > Camera follows an objectThe camera follows one object until a camera move or the end of the scene.
Logic > Set a variableSets a variable to a number or to true / false, or adds a number to it. It can be a global variable or a variable of an object.
Logic > Jump ifLooks at a variable. If it is what you asked for, the scene jumps to another step; if not, it just goes on.
Objects > Show / HideMakes an object invisible, or visible again, without destroying it.
Objects > Change Sprite or AnimationGives an object another sprite, shows one of its pictures, or changes how fast its pictures play.
Section (the + Section button)Not a step but a group of steps that you can fold shut, to keep a long scene tidy. It does not change how the scene plays.

Two of these need an explanation.

Steps that point back. Destroy, Change Position, Destroy Background, Move Background and Stop all act on something an earlier step in the same scene made. You choose which earlier step in the editor. You cannot use them on an instance that was already in the room.

Dialogue. Each Dialogue step shows up to two lines at once. The letters appear one at a time, at the speed set in Letter speed, which is how many frames pass per letter: 1 is fast, 2 is the usual, 6 or more is slow and dramatic, and 0 shows the whole line at once. Every line has its own speed, so a shout can be quick and a sad line slow; leave it empty to use the cutscene's usual speed. A line can also play a typing sound (see below). A portrait is a small picture beside the text, such as the speaker's face. The step waits until every letter is showing, then moves on when the player presses A. The lines are written in the editor and fixed. A dialogue cannot include a number your code worked out while playing.

The font. Every Dialogue step has its own Font list, and the cutscene has one more under Dialogue defaults for the steps that leave theirs at (scene default). The list holds the fonts of your project, any size the Paint tab can make. A step with no font anywhere is written in the default font, the one text drawing uses: your project's own font_default if it has one, else Gbabel's own 8 x 8 font. A font that is no longer in your project stops the build until you pick another. The size of the letters decides how the two lines are laid out, so nothing overlaps whatever you pick:

The box picture is yours, so it has to be tall enough: two lines of a 32-pixel font stand 70 pixels tall. Each different letter on screen also holds some of the console's 1024 sprite tiles, 1 for an 8-pixel font, 4 for 16, 16 for 32. The Font list says what the font you picked costs.

The text can also be small or large. Large is the font's own letters scaled up by two, so it looks blocky, and it takes the same room as a font twice the size.

A Dialogue step also has a Text effect list, for a text effect made in the Overlay Effects tab. It plays on that line's words only and ends with the line. Which lines says whether it plays on both lines (the usual), on line 1 only or on line 2 only.

Speaker and portrait picture. A Dialogue line can have a Speaker name tag, which stands on a small plate above the box, over the portrait, in the line's font (it can be no longer than a line of words). The plate is made in the dialogue box's own colors and sized to the name; in the cutscene's settings you can pick a picture of your own for it instead (Name tag picture). If the portrait picture has several pictures, such as faces for different moods, Portrait picture number picks one: 0 is the first, 1 the second, and so on.

Choices. A Dialogue can let the player answer. Press + Add answer (2 to 8 answers, each with its own words). When the line is fully shown the answers appear above the box, and the player picks one with Up, Down and A. The box shows 4 answers at a time: with more, a small ^ or v before the first or last answer says that more wait above or below, and Up and Down scroll the list. To offer an answer only sometimes, tick Show only when on it and choose a variable, a comparison and a number (for example trust is at least 3): while that is false the answer is not shown, cannot be picked, and the answers under it move up. If none is offered, the line waits for A like a plain line. The variable can be one your code sets, one a Set a Variable step sets, or one another answer sets. For each answer, Then says what comes next: go on to the next step, end the scene, or jump to a step that has a name. To give a step a name, type it in Name this step on its card (letters, numbers and _, each name used once in the scene). An answer can also set a variable to a number, so your code can tell which answer was picked. Tick Sets a variable on the answer, then choose A global (type its name) or An object's (pick an object from the drop-down, which shows your object groups as folders, then one of its number variables). It is one or the other, never both. An object's variable is set on every copy of that object that is in the room when the answer is picked. Give a global variable a starting value somewhere first, because a global that is never assigned in code is an error:

// Create event of a controller object
global.answer = 0;
// After the scene: did the player pick the answer that set it to 1?
if (global.answer == 1) {
    cutscene_start(cs_next);
}

Wait. The scene stops at this step until what you chose happens. A Wait can also sit inside a group of steps that play together, and then the group is finished only when the Wait is.

Run a Script. Pick one of your scripts and give it its values (numbers, or true and false). It runs once and the scene goes on. A script normally runs as the object that calls it, but a scene is not an object. Here the script runs as a hidden stand-in, so anything it does to "self", such as moving or drawing, shows nothing. Changing variables, giving items, opening doors, saving and creating objects all work as usual. A script that needs to know which kind of object runs it cannot be used.

Cinema. The + Cinema button holds three steps:

Set a variable. The + Logic button holds two steps. Set a variable changes a variable and goes on at once. Pick A global (the kind your code reads as global.name) and type its name, or pick An object's and choose an object and one of its variables. Then choose Set it to a number (or true / false) or Add to it a number; type a negative number to take away. A variable of an object is changed on every copy of that object in the room, the way an answer's "Sets a variable" does. A global that does not exist yet is made when the step plays, and your code can read it after the scene.

Jump if. Jump if looks at a global variable the way a Wait does ("is true", or a comparison with a number). If it is what you asked for, the scene jumps to another step; if not, it just goes on to the next one. You pick where to jump the way an answer does: first give the step you want to jump to a name with Name this step, then pick that name in the Then jump to list, or pick the end of the cutscene. You can jump forward to skip steps, or back to repeat some until a variable changes (a Set a variable step, a Dialogue answer or a script can change it). A variable that was never set counts as 0. Set a variable and Jump if are enough to make branches: one answer sets route to 2, and later a Jump if sends the scene to the steps of that route.

Show / Hide and Change Sprite. Both are in the + Objects menu, and both work on an object the same two ways: pick a Create step above (the object that step made), or pick Every copy of an object in the room (a copy you placed in the room works too, and so do the copies of its children). Show / Hide makes the object invisible or visible again. A hidden object is not drawn, but it is still there: it keeps its place, its variables and its code, and it can still be hit. Change Sprite or Animation gives the object another sprite (a character turns round, sits, waves), shows a picture of its sprite by number (the first is 0), and/or sets how fast its pictures play, in pictures a second (0 stops the animation). Whatever you leave unticked stays as it was.

Letter speed and typing sound. Letter speed is how many frames each letter waits (see Dialogue above), set on each line. A line can also play a Typing sound: pick a sound from your project. It plays as the letters appear, once for every number of letters you set (spaces make no sound), so a fast line can use 2 or 3 to avoid a clatter. A line with no typing sound is silent, as before.

Source: a dialogue from the designer. The top of every Dialogue step has a Source list. Simple dialogue (made here) is the step you already know: the words, the portrait and up to 8 answers are written right in the step. From the Dialogue designer swaps those fields for a list of the dialogues you made in the Dialogue section of the Cutscenes tab, an Open in designer button and a short summary (how it starts, how many lines it has, whether it has choices). When the cutscene reaches the step, the whole conversation plays - its choices, its branches, its characters' expressions - and then the cutscene goes on to the next step. The step is a link, not a copy: change the dialogue in the designer and every cutscene that plays it changes too. A choice sets variables as usual, so a Jump if step after it can check what the player answered. Switching Source back and forth keeps what you typed on each side. If the dialogue is deleted or renamed outside the editor, Things to fix says which step lost it, and until you pick another that step plays nothing. The Preview plays the linked conversation in place.

Portrait effect. A Dialogue line that has a portrait can give it a Portrait effect: a sprite effect from the Overlay Effects tab, worn by the face beside the words (a red tint for an angry line). The game plays the effect's Tint while the line is up; its other tracks (Wobble, Distort, Scale and so on) belong to objects and are not played on a portrait. The Dialogue designer fills this in from a character's expressions (see the Dialogue section of the Cutscenes tab).

Sections. A long scene with many branches gets hard to read. The + Section button adds a Section: a card with a name that holds steps and folds shut with its arrow. (It is called a Section because "group" already means steps that play together.) Type a name in the Section's header to rename it. Drag a step into a Section, out of it, or from one Section to another, and drag the Section's header to move the whole Section. Right-click a step to put it in a new Section, to put it in a Section next to it, or to take it out. The Section's header says how many steps it holds, and a Section you folded shut stays folded the next time you open the project. The X on a Section's header deletes it: you are asked whether to keep its steps (they stay where they are) or to delete them too.

A Section is only for tidiness. It changes nothing about how the scene plays: the steps still play in the order of the list, exactly as if the Section were not there, and an answer or a Jump if still goes to a step by its name, wherever the step is. The game that is built is exactly the same with Sections and without them. A step that plays together with the step above it is always in the same Section as that step. A Section with no steps sits at the end of the list until you drag a step into it.

Steps that play together. Tick Run with the previous step on a step card and it starts at the same moment as the step above. Those steps are a group, and the scene moves on when all of them are finished. Two Dialogue steps cannot be in one group (only one line of words fits on the screen), and neither can two camera moves. The editor says so and leaves the tick off.

Editing the timeline. Steps are never picked or highlighted: clicking a card's empty spot does nothing. Right-click a step and choose Copy, Duplicate or Delete; Paste after puts a copy after that step, and Ctrl+V pastes the copied step at the end. You can paste into a different scene. Drag a step to move it. A step that starts a group takes its group along, and a step dragged out of the middle of a group plays on its own afterwards. A step never lands inside a group. Steps that point back at an earlier step keep pointing at the right one when they move. A small bar on each card shows when the step starts and how long it lasts. A Dialogue waits for the player, so its bar is only a guess.

The waiting arrow and the answers' box. In Dialogue defaults, tick Arrow when a line waits and a small arrow bobs in the corner of the box while a finished line waits for A; it is the built-in arrow unless you pick a Waiting arrow picture of your own, a sprite 16 x 16 pixels at the most whose pictures play one after another. Panel behind answers puts a dark box with a light edge behind a Dialogue's answers. You can give the answers a box picture of your own (Answers box picture; like every background picture it is 256 x 256 or more, so draw the box, 184 pixels wide, in the picture's top-left corner), set where its top-left corner stands (Answers box position, counted from the top-left of the 240 x 160 screen), and arrange the answers as a column, a row or a 2 x 2 grid (Answers layout; a Dialogue has 4 answers at the most). In a column the player moves with Up and Down, in a row with Left and Right, in a grid with all four. The answers stand 8 pixels inside the box, each in a slot as wide as the room left divided by the columns, and a long answer is cut to its slot.

Preview. The Preview panel under the timeline plays the scene on a room without building the game: Play, Pause, Stop, and a slider to jump to any moment. It shows roughly where the camera goes, the dialogue box and its letters, objects the scene makes (standing still) and objects walking their paths. It draws the box picture and the words in your own font where the game puts them, plays text effects on the letters (on the lines you chose), draws the zoomable picture, and keeps the camera inside the room's edges. It is still only close for a few things: particles play with the same simulation as the Particles tab but only close (the game's own random numbers and its limits on how many live at once are not copied), an object a step makes stands still (what its own code does is not played), the player's real timing is not known (see Press A below), and a camera that your own code moves is not played. Previewing never changes your project.

The newer steps are shown like this:

The scene list. Right-click a scene on the left to Rename it (your code and triggers follow), Move to Group or Delete it. Groups are folders for scenes. Make one with the folder button beside the heading.

The editor also lists Change Sprite and Change Palette under the Objects menu, grayed out. The engine cannot do them yet.

Music, sounds, pictures, rooms and easing

These steps sit beside the others on the timeline. A game that uses none of them is built exactly as before.

In the preview, music and sounds appear as notes (it is silent), Go to Room fades to black and ends the scene, and pictures, easing and sprite effects are drawn.

What happens while a scene plays

Starting a scene freezes ordinary gameplay across the whole game. Step, Alarm, Button, Movement and Collision events stop, so enemies stop chasing and the player stops moving. The camera, drawing, particles, audio and tile animation keep running. This is the same freeze a room transition uses. A HUD object that only draws keeps drawing over the frozen world.

Only one scene plays at a time. While a scene plays, the buttons do only two things, and both are fixed and cannot be remapped:

When a scene ends

A scene ends when its last step finishes, or when it is skipped or stopped. Then:

Starting a scene

There are two ways.

  1. Automatically, with an Entering a room trigger. The room's own setup starts the scene each time it loads. With Once, the game records that the scene has played in the save store, using a key that begins gbcut_, so that it does not play again. That record lives in the working copy, like any save_set. It only survives switching off the console if your game calls save_commit afterwards. Without that it is once per play session. See Saving.
  2. From code, with the User scripting trigger, or from any scene whenever you like:
// Collision event of a trigger the player walks into
cutscene_start(cs_intro);

Call it once, from the moment that should start it: a Collision event, a boss's Destroy event. Do not put it in a Step event that runs every frame.

The five functions

FunctionWhat it does
cutscene_start(cs)Starts the scene. Returns true, or false if nothing started.
cutscene_active()True while a scene is playing.
cutscene_current()Which scene is playing, or nothing.
cutscene_skip()Ends the scene if it is skippable.
cutscene_stop()Ends the scene whether skippable or not.

cutscene_start returns false and changes nothing if a scene is already playing. This is deliberate: two triggers racing can never cut a running scene short by accident. To replace one on purpose, say so:

// Step event: stop whatever is playing, then start the next scene
cutscene_stop();
cutscene_start(cs_next);

A scene with no steps starts and finishes at once. cutscene_start returns true for it, but cutscene_active is never true, because there was nothing to freeze the game for.

You rarely need cutscene_skip, since START already does it. It exists for a project that wants to skip from somewhere else. Gameplay events are frozen during a scene, so it has to come from a Draw event, which is never frozen.

Where to go next

Playing a cutscene when the player enters a room is a room-entry trigger; moving from one room to another from code is covered in Moving between rooms. The camera functions the Pan and Shake steps are built from are on their own pages: camera_set and camera_shake.

See also: cutscene_startcutscene_skipcamera_shakeeffect_startbackground_createSaving a game